package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.repository.entity.RejectedProduct;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class RejectedProductVO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "退货的产品id")
    private Integer productId;

    @ApiModelProperty(value = "退货主表id")
    private Integer rejectedId;

    @ApiModelProperty(value = "退货数量")
    private Integer recededNum;

    @ApiModelProperty(value = "已处理的数量")
    private Integer handleNum;

    @ApiModelProperty(value = "增在处理的数量")
    private Integer processingNum;

    @ApiModelProperty(value = "送货数量")
    private Integer deliverNum;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static RejectedProduct convert(RejectedProductVO vo) {
        RejectedProduct entity = new RejectedProduct();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<RejectedProduct> convertList(List<RejectedProductVO> list) {
        List<RejectedProduct> resultList = new ArrayList<>();
        for (RejectedProductVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
